import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
import HomeView from '../views/HomeView.vue'
// import MainView from '../views/MainView.vue'
// import UserView from '../views/UserView.vue'
// import { useUserStore } from '@/stores/modules/user'
// import pinia from '@/stores'

// 这里要加入pinia 实例化,否则会报getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
// const userStore = useUserStore(pinia)
// const mList = ref<IRouter[]>(userStore.menuList || [])
const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'main',
    component: HomeView,
    redirect: '/home',
    children: [] // 动态路由，用户登录后加入
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/LoginView.vue')
  },
  {
    path: '/404',
    name: '404',
    component: () => import('../views/404View.vue')
  },
  {
    path: '/about',
    name: 'about',
    component: () => import('../views/AboutView.vue')
  }
]
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL), // 基地址 默认 /  这里读取vite.config.ts中的base配置
  routes
})

export default router
